<?
require_once("../config/dbconn.php");require_once("../config/powercls.php");

if($act=='chuku'){
	$msg='';
	if(trim($proid)=='') $msg.="请输入出库产品编号\\n";
	if(intval($num)==0) $msg.="请输出库数量\\n";
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	//产品编号是否cunzai
	$sqlcp="select id from {$db_prefix}products where id='$proid'";
	$rscp=$db->get_one($sqlcp);
	if (!$rscp['id']){
		$msg.="产品编号输入错误\\n";
	}
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	//插入数据库
	$dataArray['proid']=$proid;
	$dataArray['num']=intval($num);
	$dataArray['content']=addslashes($content);
	$dataArray['orderid']=$orderid;
	$dataArray['wlgs']=$wlgs;
	$dataArray['logid']=$logid;
	$dataArray['cktime']=$curtime;

	$db->insert("{$db_prefix}chuku",$dataArray);
	
	//减少库存
	$sqlgx="update {$db_prefix}products set num=num-'".intval($num)."' where id='$proid'";
	$db->query($sqlgx);
	
	echo "<script>alert('出库成功');location.href='kucun_cklst.php';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">出库</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
		<form action="?act=chuku" method="post" name="form1" id="form1">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30" colspan="3">
			  
			  <table width="100%" height="210" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" class="left_txt">出库产品编号</td>
                  <td height="30" class="left_ts"><label>
                    <input name="proid" type="text" id="proid">
                  </label>
                    *</td>
                </tr>
                <tr>
                  <td height="30" align="center" class="left_txt">出库数量</td>
                  <td height="30" class="left_txt"><input name="num" type="text" id="num" />
                    <span class="left_ts">件</span></td>
                  </tr>
				   <tr>
				     <td height="30" align="center" bgcolor="#f2f2f2" class="left_txt">订单号</td>
				     <td height="30" bgcolor="#f2f2f2" class="left_txt"><input name="orderid" type="text" id="orderid"></td>
				     </tr>
				   <tr>
				     <td height="30" align="center" bgcolor="#f2f2f2" class="left_txt">物流公司</td>
				     <td height="30" bgcolor="#f2f2f2" class="left_txt"><label>
				       <select name="wlgs" id="wlgs">
                         <option value=''>请选择物流公司</option>
                         <?
				  $sqlgs="select * from {$db_prefix}wuliu where 1";
				  $resultgs=$db->query($sqlgs);
				  while($rsgs=$db->fetch_array($resultgs)){
				  	echo "<option value='{$rsgs['gsname']}'>{$rsgs['gsname']}</option>";
				  }
				  $db->free_result($resultgs);
				  ?>
                       </select>
				     </label></td>
				     </tr>
				   <tr>
				     <td height="30" align="center" bgcolor="#f2f2f2" class="left_txt">物流单号</td>
				     <td height="30" bgcolor="#f2f2f2" class="left_txt"><input name="logid" type="text" id="logid"></td>
				     </tr>
				   <tr>
				     <td height="30" align="center" bgcolor="#f2f2f2" class="left_txt">说明</td>
				     <td height="30" bgcolor="#f2f2f2" class="left_txt">&nbsp;</td>
				     </tr>
				   <tr>
                  <td height="30" colspan="2" align="center" bgcolor="#f2f2f2" class="left_txt">
				  <script charset="utf-8" src="../kindeditor/kindeditor-min.js"></script>
			<script charset="utf-8" src="../kindeditor/lang/zh_CN.js"></script>
					<script>
					KindEditor.ready(function(K) {
						K.create('#content', {
							themeType : 'simple'
						});
					});
				</script>
				<textarea id="content" name="content" style="width:100%;height:200px;visibility:hidden;"><?=stripslashes($rs1['content'])?></textarea>				  </td>
                  </tr>
              </table></td>
            </tr>
            
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
            <tr>
              <td width="50%" height="30" align="right"><input name="id" type="hidden" id="id" value="<?=$id?>">
              <input name="pageno" type="hidden" id="pageno" value="<?=$pageno?>">
<input type="submit" value="完成以上修改" name="B1" /></td>
              <td width="6%" height="30" align="right">&nbsp;</td>
              <td width="44%" height="30"><input type="reset" value="取消设置" name="B12" /></td>
            </tr>
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
          </table>
		  </form>
		  </td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>

</body>
</html>